<?php echo $html->css("screen/staff_list_staff.css");?>
<?php echo $this->element('menu', array("active" => "10.b"));?>
<ul class="breadcrumb">
	<li>
	  <?php echo $this->Html->link(__('Staff  ', true), array('action' => 'index', 'controller' => 'staffs'), array('class'=>'fist_link'));?>
	</li>
	<li>          
	  <?php echo $this->Html->link(__('User types  ', true), array('action' => 'index'));?>
	</li>
  </ul>  
<script>	  
	$(document).ready(function(){		
		$("#StaffTypeAdminEditForm").validate({
			rules: {
				'data[StaffType][title]': {
					required: true,
					minlength: 3
				}
			},
			messages: {			
				'data[StaffType][title]': {
					required: "Please enter a User type's title",
					minlength: "This title must consist of at least 3 characters"
				}
			}
		});

	});
</script>		  
<div id="content" class="staffTypes form">
        <fieldset class="form">
		<?php echo $this->Form->create('StaffType');?>	
		<?php echo $this->Form->input('id');?>
          <div class="input">
			<?php echo $this->Form->input('title', array('label'=>'User type:','div'=>false, 'class'=>'w360')); ?>                                    
          </div>
          <label>Permissions: </label>
          <div class="table table_p_15_2 boder w360 table_form">
            <table width="100%"  cellpadding="0" cellspacing="0" align="right">
              <thead>
                <tr>
                  <td >Functionality</td>
                  <td >Access</td>
                </tr>
              </thead>
              <tbody>
			  <?php foreach ($rules as $key=>$rule):?>
                <tr>
                  <td ><?php echo $rule;?></td>
                  <td ><input name="data[Rule][]" value="<?php echo $key;?>" <?php echo ((has_in_array($key,$this->data["Rule"]))?'checked':'');?> type="checkbox" /></td>
                </tr>
				<?php endforeach;?>               
              </tbody>
            </table>
          </div>
          <div class="clear"></div>          
		  <?php echo $form->submit(__('Save', true),array('class'=>'bt bt_save','div'=>false));?>
		  <?php echo $this->Form->end();?>
        </fieldset>
     </div>
	 <?php
		function has_in_array($value, $array){
			foreach($array as $element){
				if ($value==$element["id"]) return true;
			}
			return false;
		}
	 ?>